<?php 

class NoPancangFinder{
	private $no_pancang;
	private $db;    
    private $exclude_id;
	
	public function NoPancangFinder($db, $no_pancang){
		$this->no_pancang = $no_pancang;
		$this->db 		   = $db;
	}
	
    public function exclude($id){
        $this->exclude_id = $id;
    }
    
    private function getNoPancangById($id){
        $q = "SELECT no_pancang FROM caramel_operational.penanaman WHERE id='$id'";
        return $this->db->get_var($q);
    }
    
	public function response(){
		// get no pancang
        $no_pancang = $this->getNoPancangById($this->exclude_id);
        if( $this->no_pancang == $no_pancang ){
            echo "true";
            return;
        }
        
        $q = "SELECT COUNT(*) FROM `caramel_managerial`.`pancang` WHERE `no_pancang`='".$this->no_pancang."'";
		$match = $this->db->get_var($q);
		
		if( $match )
			echo 'false';
		else
			echo 'true';
	}
}


$ref = $_SERVER['HTTP_REFERER'];
$pos = strpos($ref, 'id=')+3;
$id  = substr($ref, $pos);

// load database class handler
include_once '../config/db_config.php';
include '../library/ezsql/shared/ez_sql_core.php';
include '../library/ezsql/mysql/ez_sql_mysql.php';

// database handler
$db = new ezSQL_mysql($dbUser, $dbPass, $dbName, $dbHost);

$find = new NoPancangFinder($db, $_GET['no_pancang']);
$find->exclude($id);
$find->response();
?>